﻿// //分页开始
var pageno = 1; //当前页
var pagesize = 6; //每页多少条信息
//1
var a;
var zz;
var pageall;
//2
var a2;
var zz2;
var pageall2;
//3
var a3;
var zz3;
var pageall3;
//4
var a4;
var zz4;
var pageall4;

var flag = true;
var flag2 = true;
var flag3 = true;
var flag4 = true;
//分页
function change(e, b, c) {

    //最大页数
    if (flag) {
        a = $("#" + b + " li.news_list");
        zz = new Array(a.length);
        //alert(a.length);
        for (var i = 0; i < a.length; i++) {
            zz[i] = a[i].innerHTML;
        } //div的字符串数组付给zz

        if (zz.length % pagesize == 0) {
            pageall = zz.length / pagesize;
        }
        else {
            pageall = parseInt(zz.length / pagesize) + 1;
        }
        flag = false;
    }
    //alert(a.length);
    pageno = e;
    if (e < 1) {
        e = 1; pageno = 1;//就等于第1页 ， 当前页为1
    }
    if (e > pageall) { //如果输入页大于最大页
        e = pageall; pageno = pageall; //输入页和当前页都=最大页
    }
    $("#" + b).html("");//全部清空
    var html = "";
    for (var i = 0; i < pagesize; i++) {
        html += '<li class="news_list">' + zz[(e - 1) * pagesize + i] + '</li>';//创建一页的li列表
        if (zz[(e - 1) * pagesize + i + 1] == null) break;//超出最后的范围跳出
    }
    $("#" + b).html(html);//给ul列表写入html
    var ye = "";

    for (var j = 1; j <= pageall; j++) {
        if (e == j) {
            ye = ye + "<span><a href='#' onClick='change(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")' style='color:#ffffff;background-color:#003aa3;'>" + j + "</a></span> "
        }
        else {
            ye = ye + "<a href='#' onClick='change(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")'>" + j + "</a> "
        }
    }
    var pageContent = "";
    pageContent = pageContent + '<a href="#" onClick="change(--pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">上一页</a>';
    pageContent = pageContent + '<span id="a3">' + ye + '</span>';

    pageContent = pageContent + '<a href="#" onClick="change(++pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">下一页</a>';
    $("#" + c).html(pageContent);

}
function change2(e, b, c) {
    //最大页数
    if (flag2) {


        a2 = $("#" + b + " li.news_list");
        zz2 = new Array(a2.length);
        //alert(a.length);
        for (var i = 0; i < a2.length; i++) {
            zz2[i] = a2[i].innerHTML;
        } //div的字符串数组付给zz

        if (zz2.length % pagesize == 0) {
            pageall2 = zz2.length / pagesize;
        }
        else {
            pageall2 = parseInt(zz2.length / pagesize) + 1;
        }
        flag2 = false;
    }

    pageno = e;
    if (e < 1) {
        e = 1; pageno = 1;//就等于第1页 ， 当前页为1
    }
    if (e > pageall2) { //如果输入页大于最大页
        e = pageall2; pageno = pageall2; //输入页和当前页都=最大页
    }
    $("#" + b).html("");//全部清空
    var html = "";
    for (var i = 0; i < pagesize; i++) {
        html += '<li class="news_list">' + zz2[(e - 1) * pagesize + i] + '</li>';//创建一页的li列表
        if (zz2[(e - 1) * pagesize + i + 1] == null) break;//超出最后的范围跳出
    }
    $("#" + b).html(html);//给ul列表写入html
    var ye = "";

    for (var j = 1; j <= pageall2; j++) {
        if (e == j) {
            ye = ye + "<span><a href='#' onClick='change2(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")' style='color:#ffffff;background-color:#003aa3;'>" + j + "</a></span> "
        }
        else {
            ye = ye + "<a href='#' onClick='change2(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")'>" + j + "</a> "
        }
    }
    var pageContent = "";
    pageContent = pageContent + '<a href="#" onClick="change2(--pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">上一页</a>';
    pageContent = pageContent + '<span id="a3">' + ye + '</span>';

    pageContent = pageContent + '<a href="#" onClick="change2(++pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">下一页</a>';
    $("#" + c).html(pageContent);

}
function change3(e, b, c) {
    //最大页数
    if (flag3) {


        a3 = $("#" + b + " li.news_list");
        zz3 = new Array(a3.length);
        //alert(a.length);
        for (var i = 0; i < a3.length; i++) {
            zz3[i] = a3[i].innerHTML;
        } //div的字符串数组付给zz

        if (zz3.length % pagesize == 0) {
            pageall3 = zz3.length / pagesize;
        }
        else {
            pageall3 = parseInt(zz3.length / pagesize) + 1;
        }
        flag3 = false;
    }

    pageno = e;
    if (e < 1) {
        e = 1; pageno = 1;//就等于第1页 ， 当前页为1
    }
    if (e > pageall3) { //如果输入页大于最大页
        e = pageall3; pageno = pageall3; //输入页和当前页都=最大页
    }
    $("#" + b).html("");//全部清空
    var html = "";
    for (var i = 0; i < pagesize; i++) {
        html += '<li class="news_list">' + zz3[(e - 1) * pagesize + i] + '</li>';//创建一页的li列表
        if (zz3[(e - 1) * pagesize + i + 1] == null) break;//超出最后的范围跳出
    }
    $("#" + b).html(html);//给ul列表写入html
    var ye = "";

    for (var j = 1; j <= pageall3; j++) {
        if (e == j) {
            ye = ye + "<span><a href='#' onClick='change3(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")' style='color:#ffffff;background-color:#003aa3;'>" + j + "</a></span> "
        }
        else {
            ye = ye + "<a href='#' onClick='change3(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")'>" + j + "</a> "
        }
    }
    var pageContent = "";
    pageContent = pageContent + '<a href="#" onClick="change3(--pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">上一页</a>';
    pageContent = pageContent + '<span id="a3">' + ye + '</span>';

    pageContent = pageContent + '<a href="#" onClick="change3(++pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">下一页</a>';
    $("#" + c).html(pageContent);

}
function change4(e, b, c) {
    //最大页数
    if (flag4) {


        a4 = $("#" + b + " li.news_list");
        zz4 = new Array(a4.length);
        //alert(a.length);
        for (var i = 0; i < a4.length; i++) {
            zz4[i] = a4[i].innerHTML;
        } //div的字符串数组付给zz

        if (zz4.length % pagesize == 0) {
            pageall4 = zz4.length / pagesize;
        }
        else {
            pageall4 = parseInt(zz4.length / pagesize) + 1;
        }
        flag4 = false;
    }

    pageno = e;
    if (e < 1) {
        e = 1; pageno = 1;//就等于第1页 ， 当前页为1
    }
    if (e > pageall4) { //如果输入页大于最大页
        e = pageall4; pageno = pageall4; //输入页和当前页都=最大页
    }
    $("#" + b).html("");//全部清空
    var html = "";
    for (var i = 0; i < pagesize; i++) {
        html += '<li class="news_list">' + zz4[(e - 1) * pagesize + i] + '</li>';//创建一页的li列表
        if (zz4[(e - 1) * pagesize + i + 1] == null) break;//超出最后的范围跳出
    }
    $("#" + b).html(html);//给ul列表写入html
    var ye = "";

    for (var j = 1; j <= pageall4; j++) {
        if (e == j) {
            ye = ye + "<span><a href='#' onClick='change4(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")' style='color:#ffffff;background-color:#003aa3;'>" + j + "</a></span> "
        }
        else {
            ye = ye + "<a href='#' onClick='change4(" + j + "," + '"' + b + '"' + "," + '"' + c + '"' + ")'>" + j + "</a> "
        }
    }
    var pageContent = "";
    pageContent = pageContent + '<a href="#" onClick="change4(--pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">上一页</a>';
    pageContent = pageContent + '<span id="a3">' + ye + '</span>';

    pageContent = pageContent + '<a href="#" onClick="change4(++pageno' + ',' + "'" + b + "'" + ',' + "'" + c + "'" + ')">下一页</a>';
    $("#" + c).html(pageContent);

}
        ////分页结束